package com.heima.admin.controller;

import com.heima.admin.service.AdUserService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.AdUserLoginDto;
import com.heima.model.admin.dtos.LoginResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
public class LoginController {

    @Autowired
    private AdUserService userService;

    @PostMapping("/login/in")
    public ResponseResult<LoginResultDTO> login(@Validated @RequestBody AdUserLoginDto dto){
        LoginResultDTO result = userService.login(dto);
        return ResponseResult.ok(result);
    }

}
